/*     */ package com.umeng.common.net;
/*     */ 
/*     */ import android.app.ActivityManager;
/*     */ import android.app.ActivityManager.RunningAppProcessInfo;
/*     */ import android.app.Notification;
/*     */ import android.app.NotificationManager;
/*     */ import android.app.PendingIntent;
/*     */ import android.content.Context;
/*     */ import android.content.Intent;
/*     */ import android.content.res.Resources;
/*     */ import android.net.Uri;
/*     */ import android.os.AsyncTask;
/*     */ import android.os.Bundle;
/*     */ import android.os.Message;
/*     */ import android.os.Messenger;
/*     */ import android.os.RemoteException;
/*     */ import android.text.TextUtils;
/*     */ import android.util.SparseArray;
/*     */ import android.widget.RemoteViews;
/*     */ import android.widget.Toast;
/*     */ import com.umeng.common.Log;
/*     */ import com.umeng.common.a.a;
/*     */ import com.umeng.common.util.DeltaUpdate;
/*     */ import com.umeng.common.util.h;
/*     */ import java.io.File;
/*     */ import java.util.HashMap;
/*     */ import java.util.Iterator;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Random;
/*     */ import java.util.Set;
/*     */ 
/*     */ class d
/*     */ {
/*  51 */   private static final String c = d.class.getName();
/*     */   static final int a = 0;
/*     */   static final int b = 1;
/*     */ 
/*     */   int a(a.a parama)
/*     */   {
/*  82 */     int i = (int)((parama.b.hashCode() >> 2) + (
/*  83 */       parama.c.hashCode() >> 3) + System.currentTimeMillis());
/*  84 */     return Math.abs(i);
/*     */   }
/*     */ 
/*     */   Notification a(Context paramContext, a.a parama, int paramInt1, int paramInt2)
/*     */   {
/*  90 */     Context localContext = paramContext.getApplicationContext();
/*  91 */     Notification localNotification = new Notification(
/*  92 */       17301633, 
/*  93 */       localContext.getString(
/*  94 */       com.umeng.common.a.c.i(localContext)), 1L);
/*     */ 
/*  96 */     RemoteViews localRemoteViews = new RemoteViews(localContext.getPackageName(), 
/*  98 */       com.umeng.common.a.b.a(localContext));
/*  99 */     localRemoteViews.setProgressBar(
/* 100 */       a.b(localContext), 100, paramInt2, false);
/* 101 */     localRemoteViews.setTextViewText(
/* 102 */       a.a(localContext), paramInt2 + "%");
/* 103 */     localRemoteViews
/* 104 */       .setTextViewText(
/* 106 */       a.c(localContext), 
/* 107 */       localContext.getResources()
/* 108 */       .getString(
/* 110 */       com.umeng.common.a.c.g(localContext)) + 
/* 111 */       parama.b);
/*     */ 
/* 113 */     localNotification.contentView = localRemoteViews;
/* 114 */     localNotification.when = System.currentTimeMillis();
/* 115 */     localNotification.contentIntent = PendingIntent.getActivity(localContext, 0, 
/* 116 */       new Intent(), 134217728);
/*     */ 
/* 118 */     if (parama.g) {
/* 119 */       localNotification.flags = 2;
/* 120 */       PendingIntent localPendingIntent1 = m.b(
/* 121 */         localContext, m.a(paramInt1, 
/* 122 */         "continue"));
/* 123 */       localRemoteViews.setOnClickPendingIntent(
/* 124 */         a.d(localContext), 
/* 125 */         localPendingIntent1);
/* 126 */       localRemoteViews.setViewVisibility(
/* 127 */         a.d(localContext), 
/* 128 */         0);
/* 129 */       b(paramContext, localNotification, paramInt1);
/*     */ 
/* 131 */       PendingIntent localPendingIntent2 = m.b(
/* 132 */         localContext, m.a(paramInt1, 
/* 133 */         "cancel"));
/* 134 */       localRemoteViews.setViewVisibility(
/* 135 */         a.f(localContext), 
/* 136 */         0);
/* 137 */       localRemoteViews.setOnClickPendingIntent(
/* 138 */         a.f(localContext), 
/* 139 */         localPendingIntent2);
/*     */     } else {
/* 141 */       localNotification.flags = 16;
/* 142 */       localRemoteViews.setViewVisibility(
/* 143 */         a.d(localContext), 
/* 144 */         8);
/* 145 */       localRemoteViews.setViewVisibility(
/* 146 */         a.f(localContext), 
/* 147 */         8);
/*     */     }
/*     */ 
/* 150 */     return localNotification;
/*     */   }
/*     */ 
/*     */   boolean a(Context paramContext)
/*     */   {
/* 160 */     ActivityManager localActivityManager = (ActivityManager)paramContext
/* 161 */       .getSystemService("activity");
/* 162 */     List localList = localActivityManager
/* 163 */       .getRunningAppProcesses();
/* 164 */     if (localList == null) {
/* 165 */       return false;
/*     */     }
/* 167 */     String str = paramContext.getPackageName();
/* 168 */     for (ActivityManager.RunningAppProcessInfo localRunningAppProcessInfo : localList) {
/* 169 */       if ((localRunningAppProcessInfo.importance == 100) && 
/* 170 */         (localRunningAppProcessInfo.processName.equals(str))) {
/* 171 */         return true;
/*     */       }
/*     */     }
/* 174 */     return false;
/*     */   }
/*     */ 
/*     */   boolean a(a.a parama, boolean paramBoolean, Map<a.a, Messenger> paramMap, Messenger paramMessenger)
/*     */   {
/* 186 */     if (paramBoolean) {
/* 187 */       int i = new Random().nextInt(1000);
/* 188 */       if (paramMap != null)
/* 189 */         for (Iterator localIterator = paramMap.keySet().iterator(); localIterator.hasNext(); ) { localObject = (a.a)localIterator.next();
/* 190 */           Log.c(c, "_" + i + " downling  " + ((a.a)localObject).b + "   " + 
/* 191 */             ((a.a)localObject).c);
/*     */         }
/*     */       else {
/* 194 */         Log.c(c, "_" + i + "downling  null");
/*     */       }
/*     */     }
/* 197 */     if (paramMap == null)
/* 198 */       return false;
/* 199 */     for (Object localObject = paramMap.keySet().iterator(); ((Iterator)localObject).hasNext(); ) { a.a locala = (a.a)((Iterator)localObject).next();
/*     */ 
/* 201 */       if ((parama.e != null) && (parama.e.equals(locala.e))) {
/* 202 */         paramMap.put(locala, paramMessenger);
/* 203 */         return true;
/*     */       }
/*     */ 
/* 206 */       if (locala.c.equals(parama.c)) {
/* 207 */         paramMap.put(locala, paramMessenger);
/* 208 */         return true;
/*     */       }
/*     */     }
/* 211 */     return false;
/*     */   }
/*     */ 
/*     */   void a(Context paramContext, Notification paramNotification, int paramInt) {
/* 215 */     Context localContext = paramContext.getApplicationContext();
/* 216 */     NotificationManager localNotificationManager = (NotificationManager)localContext
/* 217 */       .getSystemService("notification");
/* 218 */     int i = a.d(localContext);
/* 219 */     paramNotification.contentView.setTextViewText(
/* 220 */       i, 
/* 221 */       localContext.getResources().getString(
/* 222 */       com.umeng.common.a.c.e(localContext
/* 223 */       .getApplicationContext())));
/* 224 */     paramNotification.contentView.setInt(i, "setBackgroundResource", 
/* 225 */       com.umeng.common.c.a(localContext).d("umeng_common_gradient_green"));
/* 226 */     localNotificationManager.notify(paramInt, paramNotification);
/*     */   }
/*     */ 
/*     */   void b(Context paramContext, Notification paramNotification, int paramInt) {
/* 230 */     Context localContext = paramContext.getApplicationContext();
/* 231 */     NotificationManager localNotificationManager = (NotificationManager)localContext
/* 232 */       .getSystemService("notification");
/* 233 */     int i = a.d(localContext);
/* 234 */     paramNotification.contentView.setTextViewText(
/* 235 */       i, 
/* 236 */       localContext.getResources().getString(
/* 237 */       com.umeng.common.a.c.d(localContext
/* 238 */       .getApplicationContext())));
/*     */ 
/* 240 */     paramNotification.contentView
/* 241 */       .setInt(i, "setBackgroundResource", com.umeng.common.c.a(localContext)
/* 242 */       .d("umeng_common_gradient_orange"));
/* 243 */     localNotificationManager.notify(paramInt, paramNotification);
/*     */   }
/*     */ 
/*     */   void a(Context paramContext, SparseArray<a> paramSparseArray, Map<a.a, Messenger> paramMap, int paramInt)
/*     */   {
/* 248 */     Context localContext = paramContext.getApplicationContext();
/* 249 */     NotificationManager localNotificationManager = (NotificationManager)localContext
/* 250 */       .getSystemService("notification");
/* 251 */     a locala = (a)paramSparseArray.get(paramInt);
/* 252 */     if (locala != null) {
/* 253 */       Log.c(c, "download service clear cache " + locala.e.b);
/* 254 */       if (locala.a != null)
/* 255 */         locala.a.a(2);
/* 256 */       localNotificationManager.cancel(locala.c);
/* 257 */       if (paramMap.containsKey(locala.e))
/* 258 */         paramMap.remove(locala.e);
/* 259 */       locala.b(paramSparseArray);
/*     */     }
/*     */   }
/*     */ 
/*     */   void a(a.a parama, long paramLong1, long paramLong2, long paramLong3)
/*     */   {
/* 266 */     if (parama.f != null) {
/* 267 */       HashMap localHashMap = new HashMap();
/* 268 */       localHashMap.put("dsize", String.valueOf(paramLong1));
/*     */ 
/* 270 */       String str1 = h.a();
/*     */ 
/* 272 */       String str2 = str1.split(" ")[1];
/* 273 */       localHashMap.put("dtime", str2);
/*     */ 
/* 275 */       float f = 0.0F;
/* 276 */       if (paramLong2 > 0L) {
/* 277 */         f = (float)paramLong1 / (float)paramLong2;
/*     */       }
/* 279 */       int i = (int)(f * 100.0F);
/* 280 */       localHashMap.put("dpcent", String.valueOf(i));
/*     */ 
/* 282 */       localHashMap.put("ptimes", String.valueOf(paramLong3));
/*     */ 
/* 284 */       a(localHashMap, false, parama.f);
/*     */     }
/*     */   }
/*     */ 
/*     */   final void a(Map<String, String> paramMap, boolean paramBoolean, String[] paramArrayOfString)
/*     */   {
/* 295 */     new Thread(new e(this, paramArrayOfString, paramBoolean, paramMap))
/* 359 */       .start();
/*     */   }
/*     */ 
/*     */   boolean a(DownloadingService paramDownloadingService, SparseArray<a> paramSparseArray, Map<a.a, Messenger> paramMap, Intent paramIntent)
/*     */   {
/*     */     try
/*     */     {
/* 366 */       Context localContext = paramDownloadingService.getApplicationContext();
/* 367 */       String str1 = paramIntent.getExtras().getString(
/* 368 */         "com.umeng.broadcast.download.msg");
/* 369 */       String[] arrayOfString = str1.split(":");
/*     */ 
/* 371 */       int i = Integer.parseInt(arrayOfString[0]);
/* 372 */       String str2 = arrayOfString[1].trim();
/* 373 */       if ((i != 0) && (!TextUtils.isEmpty(str2)) && 
/* 374 */         (paramSparseArray.indexOfKey(i) >= 0)) {
/* 375 */         a locala = (a)paramSparseArray.get(i);
/* 376 */         DownloadingService.b localb1 = locala.a;
/*     */ 
/* 378 */         if ("continue".equals(str2)) {
/* 379 */           if (localb1 == null) {
/* 380 */             Log.c(c, "Receive action do play click.");
/*     */ 
/* 386 */             if ((com.umeng.common.b.a(localContext, 
/* 386 */               "android.permission.ACCESS_NETWORK_STATE")) && 
/* 387 */               (!com.umeng.common.b.n(localContext))) {
/* 388 */               Toast.makeText(
/* 389 */                 localContext, 
/* 390 */                 localContext.getResources()
/* 391 */                 .getString(
/* 393 */                 com.umeng.common.a.c.a(localContext
/* 394 */                 .getApplicationContext())), 
/* 395 */                 1).show();
/* 396 */               return false;
/*     */             }
/*     */             DownloadingService tmp158_157 = paramDownloadingService; tmp158_157.getClass(); DownloadingService.b localb2 = new DownloadingService.b(tmp158_157, 
/* 400 */               localContext, locala.e, i, locala.d, 
/* 401 */               paramDownloadingService.n);
/* 402 */             locala.a = localb2;
/* 403 */             localb2.start();
/*     */ 
/* 405 */             b(localContext, locala.b, i);
/* 406 */             return true;
/*     */           }
/* 408 */           Log.c(c, "Receive action do play click.");
/* 409 */           localb1.a(1);
/* 410 */           locala.a = null;
/* 411 */           a(localContext, locala.b, i);
/* 412 */           return true;
/*     */         }
/* 414 */         if ("cancel".equals(str2)) {
/* 415 */           Log.c(c, "Receive action do stop click.");
/*     */           try {
/* 417 */             if (localb1 != null) {
/* 418 */               localb1.a(2);
/*     */             } else {
/* 420 */               long l1 = locala.f[0];
/* 421 */               long l2 = locala.f[1];
/* 422 */               long l3 = locala.f[2];
/* 423 */               a(locala.e, l1, l2, l3);
/*     */             }
/*     */           } catch (Exception localException2) {
/*     */           } finally {
/* 427 */             a(localContext, paramSparseArray, paramMap, i);
/*     */           }
/* 429 */           return true;
/*     */         }
/*     */       }
/*     */     }
/*     */     catch (Exception localException1) {
/* 434 */       localException1.printStackTrace();
/*     */     }
/* 436 */     return false;
/*     */   }
/*     */ 
/*     */   static class a
/*     */   {
/*     */     DownloadingService.b a;
/*     */     Notification b;
/*     */     int c;
/*     */     int d;
/*     */     a.a e;
/*  63 */     long[] f = new long[3];
/*     */ 
/*     */     public a(a.a parama, int paramInt)
/*     */     {
/*  67 */       this.c = paramInt;
/*  68 */       this.e = parama;
/*     */     }
/*     */ 
/*     */     public void a(SparseArray<a> paramSparseArray) {
/*  72 */       paramSparseArray.put(this.c, this);
/*     */     }
/*     */ 
/*     */     public void b(SparseArray<a> paramSparseArray) {
/*  76 */       if (paramSparseArray.indexOfKey(this.c) >= 0)
/*  77 */         paramSparseArray.remove(this.c);
/*     */     }
/*     */   }
/*     */ 
/*     */   class b extends AsyncTask<String, Void, Integer>
/*     */   {
/*     */     public int a;
/*     */     public String b;
/*     */     private a.a d;
/*     */     private Context e;
/*     */     private NotificationManager f;
/*     */     private SparseArray<d.a> g;
/*     */     private Map<a.a, Messenger> h;
/*     */ 
/*     */     public b(int parama, a.a paramString, String paramSparseArray, SparseArray<d.a> paramMap, Map<a.a, Messenger> arg6)
/*     */     {
/* 453 */       this.e = parama.getApplicationContext();
/* 454 */       this.f = ((NotificationManager)this.e.getSystemService("notification"));
/* 455 */       this.a = paramString;
/* 456 */       this.d = paramSparseArray;
/* 457 */       this.b = paramMap;
/*     */       Object localObject1;
/* 458 */       this.g = localObject1;
/*     */       Object localObject2;
/* 459 */       this.h = localObject2;
/*     */     }
/*     */ 
/*     */     protected void onPreExecute()
/*     */     {
/* 465 */       super.onPreExecute();
/*     */     }
/*     */ 
/*     */     protected Integer a(String[] paramArrayOfString)
/*     */     {
/* 470 */       int i = 1;
/* 471 */       i = DeltaUpdate.a(paramArrayOfString[0], paramArrayOfString[1], paramArrayOfString[2]) + 1;
/* 472 */       File localFile = new File(paramArrayOfString[2]);
/* 473 */       localFile.delete();
/* 474 */       if (i == 1) {
/* 475 */         String str = h.a(new File(paramArrayOfString[1]));
/* 476 */         if (!str.equalsIgnoreCase(this.d.e)) {
/* 477 */           Log.a(d.a(), "file patch error");
/* 478 */           i = 0;
/* 479 */           return Integer.valueOf(i);
/*     */         }
/* 481 */         Log.a(d.a(), "file patch success");
/*     */       } else {
/* 483 */         Log.a(d.a(), "file patch error");
/*     */       }
/* 485 */       return Integer.valueOf(i);
/*     */     }
/*     */ 
/*     */     protected void a(Integer paramInteger)
/*     */     {
/*     */       Object localObject1;
/*     */       Object localObject2;
/* 491 */       if (paramInteger.intValue() == 1) {
/* 492 */         localObject1 = new Notification(
/* 493 */           17301634, 
/* 494 */           this.e.getString(
/* 495 */           com.umeng.common.a.c.k(this.e)), 
/* 496 */           System.currentTimeMillis());
/* 497 */         localObject2 = new Intent("android.intent.action.VIEW");
/* 498 */         ((Intent)localObject2).addFlags(268435456);
/* 499 */         ((Intent)localObject2).setDataAndType(Uri.fromFile(new File(this.b)), 
/* 500 */           "application/vnd.android.package-archive");
/* 501 */         PendingIntent localPendingIntent = PendingIntent.getActivity(
/* 502 */           this.e, 0, (Intent)localObject2, 134217728);
/*     */ 
/* 504 */         ((Notification)localObject1).setLatestEventInfo(this.e, 
/* 505 */           com.umeng.common.b.w(this.e), this.e
/* 506 */           .getString(
/* 507 */           com.umeng.common.a.c.k(this.e)), 
/* 508 */           localPendingIntent);
/* 509 */         ((Notification)localObject1).flags = 16;
/* 510 */         this.f.notify(this.a + 1, (Notification)localObject1);
/* 511 */         boolean bool = d.this.a(this.e);
/* 512 */         if (bool) {
/* 513 */           this.f.cancel(this.a + 1);
/* 514 */           this.e.startActivity((Intent)localObject2);
/*     */         }
/* 516 */         Bundle localBundle = new Bundle();
/* 517 */         localBundle.putString("filename", 
/* 518 */           this.b);
/*     */ 
/* 520 */         Message localMessage = Message.obtain();
/* 521 */         localMessage.what = 5;
/* 522 */         localMessage.arg1 = 1;
/* 523 */         localMessage.arg2 = this.a;
/* 524 */         localMessage.setData(localBundle);
/*     */         try
/*     */         {
/* 527 */           if (this.h.get(this.d) != null) {
/* 528 */             ((Messenger)this.h.get(this.d)).send(localMessage);
/*     */           }
/* 530 */           d.this.a(this.e, this.g, this.h, this.a);
/*     */         } catch (RemoteException localRemoteException2) {
/* 532 */           d.this.a(this.e, this.g, this.h, this.a);
/*     */         }
/*     */       }
/*     */       else {
/* 536 */         this.f.cancel(this.a + 1);
/* 537 */         localObject1 = new Bundle();
/* 538 */         ((Bundle)localObject1).putString("filename", 
/* 539 */           this.b);
/*     */ 
/* 541 */         localObject2 = Message.obtain();
/* 542 */         ((Message)localObject2).what = 5;
/* 543 */         ((Message)localObject2).arg1 = 3;
/* 544 */         ((Message)localObject2).arg2 = this.a;
/* 545 */         ((Message)localObject2).setData((Bundle)localObject1);
/*     */         try
/*     */         {
/* 548 */           if (this.h.get(this.d) != null) {
/* 549 */             ((Messenger)this.h.get(this.d)).send((Message)localObject2);
/*     */           }
/* 551 */           d.this.a(this.e, this.g, this.h, this.a);
/*     */         } catch (RemoteException localRemoteException1) {
/* 553 */           d.this.a(this.e, this.g, this.h, this.a);
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.common.net.d
 * JD-Core Version:    0.6.2
 */